////////////////////////////////////////////////////////////////////////////////
//                                                                            //
//                           BailterRay                                       //
//                    Pip Robbins & Zhao Zhang                                //
//                                                                            //
////////////////////////////////////////////////////////////////////////////////
class BailterRayHealthHeal extends BailterRayPickupFactory
                placeable;

var() int HealAmount;
var BailterRayHUD MyHud;
var	SoundCue ErrorSound;

function SpawnCopyFor( Pawn Recipient )
{
    local BailterRayPlayerController BPC;
	if ( UTPawn(Recipient) == None )
		return;


	Recipient.MakeNoise(0.2);
	AddHealth(UTPawn(Recipient));
	BPC = BailterRayPlayerController(Recipient.Controller);
	if(BPC != none)
	{
	    MyHud = BailterRayHUD(BPC.myHUD);
        MyHud.PickupTextureType = 3;
        MyHud.bShowPickupDes = true;
        setTimer(3,false,'DisableDescription') ;
	}
	super.SpawnCopyFor(Recipient);
	PickupEffect.SetScale(1);
}


function DisableDescription()
{
    if(MyHud != none)
    {
        MyHud.bShowPickupDes = false;
        //MyHud.PickupDesCounter[3]++;
    }
}

function AddHealth(UTPawn P)
{
    if(P.Health <= P.HealthMax - 20)
    	P.Health += HealAmount;
   	if(P.Health > P.HealthMax - 20)
   	    P.Health = P.HealthMax;
}

auto state Pickup
{
	function bool ValidTouch( Pawn Other )
	{
		if ( !Super.ValidTouch(Other) )
		{
			return false;
		}
		if(Other.Health == 100)
		{
            Other.PlaySound( ErrorSound );
        	Other.MakeNoise(0.2);
        	return false;
		}
		return true;
	}
}


defaultproperties
{
   HealAmount=20
   PickupSound=SoundCue'BailterRaySoundPackages.PICKUPS.Pickup_SoundCue'
   ErrorSound=SoundCue'BailterRaySoundPackages.PICKUPS.Pickup_ErrorCue'
      Begin Object class=StaticMeshComponent Name=HealthPickUpComp
      StaticMesh=StaticMesh'BailterRayAssetPackageLevel1.Powerups.HealthCase'
      Translation = (X=0, Y=0, Z=-25)
      Scale3D=(X=1.30000,Y=1.30000,Z=1.3000)
   End Object
   PickupMesh=HealthPickUpComp
   Components(6)=HealthPickUpComp
   ParticleEffectsGlow=ParticleSystem'BailterRayAssetPackageLevel1.Powerups.Powerups_Spawn_Effect'
}